home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / BC_TI.ARJ / TI716.ASC < prev    next >
Text File  |  1992-02-25  |  5KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                            NUMBER  :  716
  9.   VERSION  :  2.0
  10.        OS  :  DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/4
  12.  
  13.     TITLE  :  Switching Between 25 and 43 Line Mode on EGA
  14.  
  15.  
  16.  
  17.  
  18.   /*************************************************************
  19.      This program shows how to switch between 25 and 43 line mode
  20.      on an EGA.
  21.   *************************************************************/
  22.  
  23.   #include <process.h>
  24.   #include <conio.h>
  25.   #include <dos.h>
  26.   #include <stdio.h>
  27.  
  28.   #define OFF 0
  29.   #define ON  1
  30.   #define NOCHANGE 2
  31.  
  32.   #define TRUE  1
  33.   #define FALSE 0
  34.  
  35.   void normvideo(void);
  36.   int  in43linemode(void);
  37.   void ega43(int mode);
  38.   int  egainstalled(void);
  39.   void setcursor(unsigned char start, unsigned char end);
  40.   int  egacursoremu(int mode);
  41.   int  egacursorsize(void);
  42.   extern unsigned char _video[];
  43.   void main(int argc, char *argv[])
  44.   {
  45.       int toggle = NOCHANGE, i;
  46.       _video[3] = 42;
  47.       _video[7] = 43;
  48.       if (!egainstalled()) {
  49.           fprintf(stderr, "EGA not installed.\n");
  50.           exit(1);
  51.       }
  52.  
  53.       if (argc >= 2)
  54.           switch(argv[1][0]) {
  55.               case '?': toggle = NOCHANGE;
  56.                         printf("usage: EGA43 [1][0]\n"
  57.                                "1 = 43-line mode; "
  58.                                "0 = 25-line mode; "
  59.                                "no argument = toggle mode\n"
  60.                               );
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                            NUMBER  :  716
  75.   VERSION  :  2.0
  76.        OS  :  DOS
  77.      DATE  :  February 25, 1992                        PAGE  :  2/4
  78.  
  79.     TITLE  :  Switching Between 25 and 43 Line Mode on EGA
  80.  
  81.  
  82.  
  83.  
  84.                         printf("43-line mode: %s\n",
  85.                                 in43linemode() ? "ON": "OFF");
  86.                         printf("Cursor size : %d\n",
  87.                                 egacursorsize());
  88.                         break;
  89.               case '0': toggle = OFF;
  90.                         break;
  91.               case '1': toggle = ON;
  92.                         break;
  93.               default : toggle = NOCHANGE;
  94.            }
  95.  
  96.  
  97.  
  98.       if (argc == 1)
  99.           switch(in43linemode()) {
  100.               case TRUE:  toggle = OFF; /*if already on, turn off*/
  101.                           break;
  102.               case FALSE: toggle = ON; /* if already off, turn on*/
  103.                           break;
  104.           }
  105.  
  106.       if (toggle != NOCHANGE) normvideo();
  107.  
  108.       if (toggle == ON)  ega43(ON);
  109.       if (toggle == OFF) ega43(OFF);
  110.       for (i=0;i<43;i++) cprintf("%d\r\n",i);
  111.       getch();
  112.   }
  113.  
  114.  
  115.   void normvideo(void)
  116.   {
  117.       union REGS regs;
  118.  
  119.       regs.h.ah = 0;
  120.       regs.h.al = 3;
  121.       int86(0x10, ®s, ®s);
  122.  
  123.   }
  124.  
  125.   void ega43(int mode)
  126.   {
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Borland C++                            NUMBER  :  716
  141.   VERSION  :  2.0
  142.        OS  :  DOS
  143.      DATE  :  February 25, 1992                        PAGE  :  3/4
  144.  
  145.     TITLE  :  Switching Between 25 and 43 Line Mode on EGA
  146.  
  147.  
  148.  
  149.  
  150.       union REGS regs;
  151.  
  152.       if (mode == OFF)
  153.           regs.h.al = 0x11;
  154.       else
  155.           regs.h.al = 0x12;
  156.  
  157.       regs.h.ah = 0x11;
  158.       regs.h.bl = 0;
  159.  
  160.       int86(0x10, ®s, ®s);
  161.  
  162.       egacursoremu(mode);
  163.   }
  164.  
  165.   int egainstalled(void)
  166.   {
  167.       union REGS regs;
  168.  
  169.       regs.x.ax = 0x1200;
  170.       regs.x.bx = 0x0010;
  171.       regs.x.cx = 0xFFFF;
  172.  
  173.       int86(0x10, ®s, ®s);
  174.  
  175.       if (regs.x.cx == 0xFFFF)
  176.           return(FALSE);
  177.       else
  178.           return(TRUE);
  179.   }
  180.  
  181.   void setcursor(unsigned char start, unsigned char end)
  182.   {
  183.       union REGS regs;
  184.  
  185.       regs.h.ah = 1;
  186.       regs.h.ch = start;  /* starting scan line */
  187.       regs.h.cl = end;    /* ending scan line   */
  188.  
  189.       int86(0x10, ®s, ®s);
  190.  
  191.   }
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Borland C++                            NUMBER  :  716
  207.   VERSION  :  2.0
  208.        OS  :  DOS
  209.      DATE  :  February 25, 1992                        PAGE  :  4/4
  210.  
  211.     TITLE  :  Switching Between 25 and 43 Line Mode on EGA
  212.  
  213.  
  214.  
  215.  
  216.   int egacursoremu(int mode)
  217.   {
  218.       unsigned char far *emulation = MK_FP(0x40,0x87);
  219.  
  220.       if (mode == OFF) {
  221.           *emulation &= ~0x01;
  222.           setcursor(6, 7);
  223.       }
  224.       else {
  225.           *emulation |= 0x01;
  226.           setcursor(5, 7);
  227.       }
  228.  
  229.       return(mode);
  230.   }
  231.  
  232.   int in43linemode(void)
  233.   {
  234.       unsigned char far *egamode = MK_FP(0x40,0x84);
  235.  
  236.       return ( (*egamode == 42)? TRUE: FALSE);
  237.  
  238.   }
  239.  
  240.   int egacursorsize(void)
  241.   {
  242.       unsigned char far *size = MK_FP(0x40, 0x85);
  243.  
  244.       return( (int) *size);
  245.   }
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.